# encoding: utf-8
"""
@author: 夏洛
@QQ: 1972386194
@file: 03-线程池.py
"""

# with as

'''
上下文机制 

'''

import time
from concurrent.futures import ThreadPoolExecutor
import requests
def crawl(url):
    res =requests.get(url)
    print(res)

if __name__ == '__main__':
    base_url = 'https://cs.fang.lianjia.com/loupan/pg{}/?_t=1/'
    start = time.time()
    # with ThreadPoolExecutor(10) as f:
    #     for i in range(1,15):
    #         f.submit(crawl,url=base_url.format(i))
    for i in range(1, 15):
        crawl(base_url.format(i))
    end_time = time.time() - start
    print(end_time,'结束时间')
